<?php

App::uses('CrudController', 'Controller');

class MoesController extends CrudController
{
    public $_model = 'Moe';

    /**
     * Administracion de los MOEs
     */
    public function admin() {
        $this->request->allowMethod('get');
        $appBosch = new stdClass();
        $this->set('appBosch', $appBosch);
        $this->set('title', __('MOES'));
        $this->set('description', __('Administración'));
    }

    protected function getRecords($param = null) {
        $m = $this->_model;
        $records = $this->$m->getEnabled();
        return $records;
    }

    protected function c($model) {
        return array(
            'text' => $model->text,
            'name' => $model->text,
            'color' => $model->color
        );
    }

    protected function u($model) {
        return array(
            'text' => $model->text,
            'name' => $model->text,
            'color' => $model->color
        );
    }

    protected function id($model) {
        return $model->value;
    }

    public function getMoes($na = null)
    {
        $this->request->allowMethod('get');
        $m = $this->_model;
        $this->loadModel($m);
        $records = $this->$m->getEnabled();
        if ($na != null) {
            $records = array(array("text" => 'N/A', "value" => null));
        }
        $this->set(array('records' => $records, '_serialize' => 'records'));
        $this->viewClass = 'Json';
    }
}
